home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_11 / nelson / chandle.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-12  |  2.5 KB  |  67 lines

  1. /* ----------------------------------------------------
  2.  *  Listing 5
  3.  *
  4.  *  chandle.h
  5.  *  Adds character-device specific capability to
  6.  *  class IoctlHandle
  7.  * ------------------------------------------------- */
  8.  
  9. #ifndef __CHANDLE_H
  10. #define __CHANDLE_H
  11. #include "iohandle.h"
  12.  
  13. //ANSI display information ......
  14. struct ANSIdata   {
  15.     char info;       //info level (=0)
  16.     char zero_1;        //reserved (=0)
  17.     int block_length;   //param block length
  18.                         //(start at next field)
  19.     int flags;      //0x0001 = intense
  20.                     //0x0002 = blink
  21.                     //other bits reserved (=0)
  22.     char mode;      //1 = text, 2 = graphics
  23.     char zero_2;    //reserved (=0)
  24.     int numcolors;  //# colors (= 2**n, where
  25.                     // n == 0, 1, 2, 4, 8;
  26.                     // 0 == monochrome )
  27.     int pix_cols;   //pixel columns
  28.     int pix_rows;   //pixel rows
  29.     int txt_cols;   //text columns
  30.     int txt_rows;   //text rows
  31.     };
  32.  
  33. class charHandle : public IoctlHandle   {
  34. protected:
  35.     int _cat;        //current device category
  36.     charHandle( const char *device );  //constructor
  37.     void handle_info( int, unsigned ); //set dev info
  38.     unsigned ioctl_data( ioctl_cmd fn, unsigned count,
  39.                                        void *buffer );
  40.     int char_ioctl( char_cmd minor_code,
  41.                     void *param_block    );
  42. public:
  43.     static charHandle *Init(const char *device );
  44.     ~charHandle() { }   //~IoctlHandle() closes _handle
  45.     int deviceCat(void) { return _cat; }
  46.     unsigned setDeviceInfo( unsigned newinfo )
  47.         {   handle_info( _handle, newinfo );
  48.             return handleInfo();        }
  49.     int isCooked( void)       //!0 if ASCII mode
  50.         { return !(binary & _info);   }
  51.     int isRaw( void )         //!0 if Binary mode
  52.         { return  (binary & _info); }
  53.     int hasIoctlChar(void)  { return ioctl & _info; }
  54.     int deviceReadyIn(void )  //!0=ready, 0 not ready
  55.         {   return inputStatus(); }
  56.     int deviceReadyOut(void)  //!0=ready, 0 not ready
  57.         {   return outputStatus(); }
  58.     int sendIoctl( unsigned *count, void *data);
  59.     int readIoctl( unsigned *count, void *data);
  60.     unsigned busyCount( void );  //get count
  61.     unsigned busyCount( unsigned count );  //set count
  62.     int getANSIdata( struct ANSIdata *dis);
  63.     int setANSIdata( struct ANSIdata *dis);
  64. };  //.... end class charHandle
  65. #endif // __CHANDLE_H
  66. /* ----- End of File ------------------------------- */
  67.